function one() {
	$.ajax({
		//http://localhost:8080/commodity/commodtiy/commodtiyList.do
		url:path + "/commodtiy/commodtiyList.do",
		type:"post",
		dataType : "json",
		success : function(result) {
			if (result.status == 1) {
				alert(result.msg);

			} else if (result.status == 0) {
				for(var i=0;i<result.data.length;i++){
					var id = result.data[i].sid;
					var name = result.data[i].sname;
					var price = result.data[i].sprice;
					var num = result.data[i].snum;
					var leib = result.data[i].sleib;
					
					$("#tb").append(
							"<tr class='row1'>"+
								"<td>"+id+"</td>"+
								"<td>"+name+"</td>"+
								"<td>"+price+"</td>"+
								"<td>"+num+"</td>"+
								"<td>"+leib+"</td>"+
							"</tr>"
							);
				}
			}
		},
		error : function() {
			alert("查询失败");
		}
	});
}
function two() {
	$.ajax({
		//http://localhost:8080/commodity/commodtiy/commodtiyList.do
		url:path + "/commodtiy/commodtiyList.do",
		type:"post",
		dataType : "json",
		success : function(result) {
			if (result.status == 1) {
				alert(result.msg);

			} else if (result.status == 0) {
				for(var i=0;i<result.data.length;i++){
					var id = result.data[i].sid;
					var name = result.data[i].sname;
					var price = result.data[i].sprice;
					var num = result.data[i].snum;
					var leib = result.data[i].sleib;
					
					$("#tb").append(
							"<tr class='row1'>"+
								"<td>"+id+"</td>"+
								"<td>"+name+"</td>"+
								"<td>"+price+"</td>"+
								"<td>"+num+"</td>"+
								"<td>"+leib+"</td>"+
								"<td>"+
								"<a onclick='delete1(this)'>删除</a>&nbsp;"+
							    "</td>"+
							"</tr>"
							);
				}
			}
		},
		error : function() {
			alert("查询失败");
		}
	});
}
function three() {
	$.ajax({
		//http://localhost:8080/commodity/commodtiy/commodtiyList.do
		url:path + "/commodtiy/commodtiyList.do",
		type:"post",
		dataType : "json",
		success : function(result) {
			if (result.status == 1) {
				alert(result.msg);

			} else if (result.status == 0) {
				for(var i=0;i<result.data.length;i++){
					var id = result.data[i].sid;
					var name = result.data[i].sname;
					var price = result.data[i].sprice;
					var num = result.data[i].snum;
					var leib = result.data[i].sleib;
					
					$("#tb").append(
							"<tr class='row1'>"+
								"<td>"+id+"</td>"+
								"<td>"+name+"</td>"+
								"<td>"+price+"</td>"+
								"<td>"+num+"</td>"+
								"<td>"+leib+"</td>"+
								"<td>"+
								"<a onclick='toUpdate(this)'>修改</a>"+
							    "</td>"+
							"</tr>"
							);
				}
			}
		},
		error : function() {
			alert("查询失败");
		}
	});
}

function delete1(obj){
	console.log(obj.parentElement.parentElement.children[0].innerHTML);
	var id = obj.parentElement.parentElement.children[0].innerHTML;
	$.ajax({
		//http://localhost:8080/commodity/commodtiy/commodtiydelete.do?id=19
		url : path + "/commodtiy/commodtiydelete.do",
		type : "post",
		data:{"id":id},
		dataType : "json",
		success : function(result) {
			if (result.status == 1) {
				alert(result.msg);
			}else if(result.status == 0){
				alert(result.msg);
				window.location.href="one.jsp";
			}
		},
		error : function() {
			alert("删除失败");
		}
	})
}

function toUpdate(obj) {
	console.log(obj.parentElement.parentElement.children[0].innerHTML);
	var id = obj.parentElement.parentElement.children[0].innerHTML;
	window.location.href="update.jsp?id="+id;
}

